<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=9,IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta charset="UTF-8">
    <title>众筹订单</title>
</head>
<style>
    .mui-content { background: #efeff4; }
    .mui-control-content { height: 100%; position: initial; }
    .mui-table-view{ margin-top: 10px; background: #efeff4; }
    .mui-table-view:before { display: none; }
    .mui-table-view:after { display: none; }
    .mui-content:after{ display: block; content: ''; clear: both; }
    div.top-nav-comment#topNavComment a{ margin-bottom: 0; padding: 20px 10px 10px 10px; }
    div.goodsBox{ margin-bottom: 10px; background-color: #fff; padding: 1rem 1rem 0 1rem; }
    div.goodsBox p{ padding: 0 0 10px 0; }
    div.goodsBox:after{ display: block; content: ''; clear: both; }
    li.order_li:first-child{ margin-top: 8px; }
    .mui_comm_ul .mui_comm_li{ font-size: 1.2rem; }
    .mui_comm_ul .mui_comm_li.left{ border-right: 1px solid #e8e8e8; }
    .mui_comm_ul .mui_comm_li.right{ color: #29bc4f; }
</style>
<div class="mui-content">
    <div>
        <div id="item1" class="mui-control-content mui-active">
            <div class="content-list-wrap">
                <div class="mui-content mui-scroll-wrapper" id="commentListWrap">
                    <div class="mui-scroll">
                        <ul class="mui-table-view" id="payed">
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 评论 -->
<script type="text/html" id="tpl-order">
    {{each list as value i}}
    <li class="order_li">
        <div class="goodsBox">
            <p>商品名称：<span style="color: #000">{{value.busi_name}}</span></p>
            <p>下单日期：<span style="color: #000">{{dataFormat(value.create_time,'yyyy年MM月dd日')}}</span></p>
            <p>订单费用：<span style="color: #000">{{dealAmount(value.price)}}元</span></p>
            <p>订单状态：<span style="color: #000">{{orderStatusText value.status}}</span></p>
            {{if value.status == 1}}
            <ul class="mui_comm_ul">
                <li class="mui_comm_li left" data-id="{{value.id}}" id="delOrder">
                    <span>取消</span>
                </li>
                <li class="mui_comm_li right" data-id="{{value.id}}" id="pay" >
                    <span>立即支付</span>
                </li>
            </ul>
            {{/if}}
        </div>
    </li>
    {{/each}}
</script>

<script>
    var _messageIndex = 1,message_page = 0;

    function payedPullUp2Refresh() {
        var _this = this;
        if (_messageIndex < message_page) {
            $.ajax({
                url: _basePath + "/app/member/listMineOrder",
                data: {
                    curPage: _messageIndex + 1,
                },
                dataType: 'json',
                success: function (data) {
                    message_page = data.resultList.totalPage;
                    var _html = template('tpl-order', data.resultList);
                    $("#payed").append(_html);
                    _messageIndex++;
                    //如果存在数据，则继续添加数据
                    if (_messageIndex < message_page) {
                        _this.endPullupToRefresh(false);
                    } else {
                        _this.endPullupToRefresh(true);
                    }
                }
            });
        } else {
            _this.endPullupToRefresh(true);
        }
    }


    $(function () {

        $.ajax({
            url: _basePath + "app/act/getFundOrder",
            data: {
                interaction_id: '${id}'
            },
            dataType: 'json',
            success: function (data) {
                if(typeof data.resultList != undefined && data.resCode == 0) {
                    var _html = template('tpl-order', data.resultList);
                    $("#payed").append(_html);
                    message_page = data.resultList.totalPage;
                    initPayedPullUp();
                }
            }
        });

    });

    function initPayedPullUp() {
        //初始化上拉加载
        mui('#commentListWrap').pullRefresh({
            up: {
                auto:false,
                contentrefresh: "正在加载...",
                contentnomore: "没有更多数据了",
                callback: payedPullUp2Refresh
            }
        });
    }

</script>

